<template>
	<view>
		<view class="head">
			<view class="head-left">
				<view class="head-left-img" :style="imgUrl"></view>
				<view class="head-left-name">{{name}}</view>
			</view>
			<view class="head-right">积分余额:{{cion}}</view>
		</view>
		<view class="nav">
			<navigator :url="item.url" hover-class="none" class="item" v-for="(item,index) in navList" :key="index">
				<i :style="'color:'+item.color" :class="item.icon"></i>
				<view>{{item.name}}</view>
			</navigator>
		</view>
		<!-- 底部 -->
		<my-bottom :buttomIndex="2"></my-bottom>
	</view>
</template>

<script>
	import myBottom from './components/bottom.vue';
	export default {
		components: {
			myBottom
		},
		data() {
			return {
				navList: [{
						'icon': 'iconfont iconrili',
						'name': '积分日志',
						'color': '#E5D11D',
						'url': '/pages/mine/study'
					},
					{
						'icon': 'iconfont iconbangzhuzhongxin',
						'name': '帮助中心',
						'color': '#E29A1F',
						'url': 'help'
					},
					{
						'icon': 'iconfont iconkefu',
						'name': '联系我们',
						'color': '#1F9BEE',
						'url': 'relation'
					},
					{
						'icon': 'iconfont1 iconweizhi-xian',
						'name': '地址管理',
						'color': '#3EC858',
						'url': 'address'
					},
				],
				name: '',
				imgUrl: '',
				cion: 0
			}
		},
		onShow() {
			this.getInfo();
		},
		methods: {
			/* 获取用户数据信息 */
			getInfo() {
				this.$zapi.apiPost('user/currency.basic/GetUserInfo').then(res => {
					if (res.data.code == 200) {
						var data = res.data.data;
						this.name = data.nicheng; //学生姓名
						if (this.name == '') {
							this.name = '未设置昵称';
						}
						this.cion = data.cion;
						this.imgUrl = data.avatar == '' ? this.imgUrl : `background-image: url('${data.avatar}')`;
						console.log(this.imgUrl);
					}
				});
			},
		},
	}
</script>

<style lang="scss">
	page {
		background: #FAFAFA;
	}

	.head {
		width: 100%;
		height: 212upx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		background-image: url(../../static/image/shopBg.png);
		background-size: 100% 100%;

		.head-left {
			display: flex;
			justify-content: flex-start;
			align-items: center;
			margin-left: 30upx;

			.head-left-img {
				background-size: cover;
				width: 112upx;
				height: 112upx;
				border-radius: 50%;
				overflow: hidden;
				border: 1upx solid #FAFAFA;

				image {
					width: 100%;
					height: 100%;
				}
			}

			.head-left-name {
				font-size: 26upx;
				margin-left: 15upx;
				font-size: 28upx;
				color: #FFFFFF;
			}
		}

		.head-right {
			background: #FFFFFF;
			border-radius: 20upx 0upx 0upx 20upx;
			height: 40upx;
			min-width: 148upx;
			font-size: 20upx;
			text-align: center;
			color: #FF9900;
			padding: 0upx 15upx;
		}

	}

	.nav {
		width: 690upx;
		display: flex;
		justify-content: space-between;
		margin: auto;
		border-radius: 20upx;
		background: #FFFFFF;
		padding: 30upx 0upx;
		margin-top: 30upx;

		.item {
			width: 25%;
			display: flex;
			justify-content: center;
			align-items: center;
			flex-direction: column;

			i {
				font-size: 60upx;
				line-height: 80upx;
			}

			view {
				font-size: 26upx;
				color: #333333;
			}

		}
	}
</style>
